/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Comunicacion;

import java.util.Vector;

/**
 *
 * @author michael
 */
public class MailBox {
    private Vector<Listener> subscribers;
    private String name;
    MailBox(String name) {
        this.name = name;
        this.subscribers = new Vector<Listener>();
    }
    public void addSubscriber(Listener sub){
        subscribers.add(sub);
    }
    synchronized public void notify(String msg){
        for(int i=0;i<subscribers.size();i++){
            subscribers.get(i).sendMsg(msg);
        }
    }
    public String getName(){
        return this.name;
    }
}
